package ledger

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models"
)

// ==================== 商户分账查询 ====================

// MerchRevQueryRequest 商户分账查询请求
type MerchRevQueryRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchRevQueryRequest 创建商户分账查询请求
func NewMerchRevQueryRequest() *MerchRevQueryRequest {
	req := &MerchRevQueryRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchRevQueryRequest) SetOrgCode(orgCode string) *MerchRevQueryRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchRevQueryRequest) SetMchID(mchID string) *MerchRevQueryRequest {
	r.MchID = mchID
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchRevQueryRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchRevQueryRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchRevQueryRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchRevQueryRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchRevQueryRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchRevQueryResponse 商户分账查询响应
type MerchRevQueryResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// MerchType 商户类型
	MerchType string `json:"merch_type,omitempty"`
	// LicenseNumber 营业执照号
	LicenseNumber string `json:"license_number,omitempty"`
	// LicenseName 营业执照名称
	LicenseName string `json:"license_name,omitempty"`
	// LicenseAddress 营业执照地址
	LicenseAddress string `json:"license_address,omitempty"`
	// LicenseBeginDate 营业执照开始日期
	LicenseBeginDate string `json:"license_begin_date,omitempty"`
	// LicenseEndDate 营业执照结束日期
	LicenseEndDate string `json:"license_end_date,omitempty"`
	// LegalName 法人姓名
	LegalName string `json:"legal_name,omitempty"`
	// LegalNumber 法人证件号
	LegalNumber string `json:"legal_number,omitempty"`
	// LegalBeginDate 法人证件开始日期
	LegalBeginDate string `json:"legal_begin_date,omitempty"`
	// LegalEndDate 法人证件结束日期
	LegalEndDate string `json:"legal_end_date,omitempty"`
	// Mobile 手机号
	Mobile string `json:"mobile,omitempty"`
	// BankCardNo 银行卡号
	BankCardNo string `json:"bank_card_no,omitempty"`
	// BankCardName 银行卡姓名
	BankCardName string `json:"bank_card_name,omitempty"`
	// BankCode 银行代码
	BankCode string `json:"bank_code,omitempty"`
	// BankName 银行名称
	BankName string `json:"bank_name,omitempty"`
	// BankBranchCode 银行支行代码
	BankBranchCode string `json:"bank_branch_code,omitempty"`
	// BankBranchName 银行支行名称
	BankBranchName string `json:"bank_branch_name,omitempty"`
	// ApplyStatus 申请状态
	ApplyStatus string `json:"apply_status,omitempty"`
}

// NewMerchRevQueryResponse 创建商户分账查询响应
func NewMerchRevQueryResponse() *MerchRevQueryResponse {
	return &MerchRevQueryResponse{}
}

// ==================== 商户分账解绑 ====================

// MerchRevUnbindRequest 商户分账解绑请求
type MerchRevUnbindRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// RevMchID 接收方商户号
	RevMchID string `json:"rev_mch_id,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchRevUnbindRequest 创建商户分账解绑请求
func NewMerchRevUnbindRequest() *MerchRevUnbindRequest {
	req := &MerchRevUnbindRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchRevUnbindRequest) SetOrgCode(orgCode string) *MerchRevUnbindRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchRevUnbindRequest) SetMchID(mchID string) *MerchRevUnbindRequest {
	r.MchID = mchID
	return r
}

// SetRevMchID 设置接收方商户号
func (r *MerchRevUnbindRequest) SetRevMchID(revMchID string) *MerchRevUnbindRequest {
	r.RevMchID = revMchID
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchRevUnbindRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchRevUnbindRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchRevUnbindRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchRevUnbindRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}
	if r.RevMchID != "" {
		baseMap["rev_mch_id"] = r.RevMchID
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchRevUnbindRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchRevUnbindResponse 商户分账解绑响应
type MerchRevUnbindResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// RevMchID 接收方商户号
	RevMchID string `json:"rev_mch_id,omitempty"`
}

// NewMerchRevUnbindResponse 创建商户分账解绑响应
func NewMerchRevUnbindResponse() *MerchRevUnbindResponse {
	return &MerchRevUnbindResponse{}
}

// ==================== 商户文件上传 ====================

// MerchFileUploadRequest 商户文件上传请求
type MerchFileUploadRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// FileBase64 文件base64编码
	FileBase64 string `json:"file_base64,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchFileUploadRequest 创建商户文件上传请求
func NewMerchFileUploadRequest() *MerchFileUploadRequest {
	req := &MerchFileUploadRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchFileUploadRequest) SetOrgCode(orgCode string) *MerchFileUploadRequest {
	r.OrgCode = orgCode
	return r
}

// SetFileBase64 设置文件base64编码
func (r *MerchFileUploadRequest) SetFileBase64(fileBase64 string) *MerchFileUploadRequest {
	r.FileBase64 = fileBase64
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchFileUploadRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchFileUploadRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchFileUploadRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchFileUploadRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.FileBase64 != "" {
		baseMap["file_base64"] = r.FileBase64
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchFileUploadRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchFileUploadResponse 商户文件上传响应
type MerchFileUploadResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// SourceID 文件源ID
	SourceID string `json:"source_id,omitempty"`
	// FileName 文件名
	FileName string `json:"file_name,omitempty"`
	// FileSize 文件大小
	FileSize string `json:"file_size,omitempty"`
	// FileType 文件类型
	FileType string `json:"file_type,omitempty"`
	// UploadTime 上传时间
	UploadTime string `json:"upload_time,omitempty"`
}

// NewMerchFileUploadResponse 创建商户文件上传响应
func NewMerchFileUploadResponse() *MerchFileUploadResponse {
	return &MerchFileUploadResponse{}
}

// ==================== 商户分账开通 ====================

// MerchIssueOpenRequest 商户分账开通请求
type MerchIssueOpenRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// LedgerModule 账本模块
	LedgerModule string `json:"ledger_module,omitempty"`
	// MaxSplitRate 最大分账比例
	MaxSplitRate string `json:"max_split_rate,omitempty"`
	// SourceIDs 文件源ID列表
	SourceIDs []string `json:"source_ids,omitempty"`
	// FeeRate 费率
	FeeRate string `json:"fee_rate,omitempty"`
	// Pbthf 平台补贴后费率
	Pbthf string `json:"pbthf,omitempty"`
	// LowAmt 最低金额
	LowAmt string `json:"low_amt,omitempty"`
	// UpAmt 最高金额
	UpAmt string `json:"up_amt,omitempty"`
	// NotifyURL 通知URL
	NotifyURL string `json:"notify_url,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchIssueOpenRequest 创建商户分账开通请求
func NewMerchIssueOpenRequest() *MerchIssueOpenRequest {
	req := &MerchIssueOpenRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchIssueOpenRequest) SetOrgCode(orgCode string) *MerchIssueOpenRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchIssueOpenRequest) SetMchID(mchID string) *MerchIssueOpenRequest {
	r.MchID = mchID
	return r
}

// SetLedgerModule 设置账本模块
func (r *MerchIssueOpenRequest) SetLedgerModule(ledgerModule string) *MerchIssueOpenRequest {
	r.LedgerModule = ledgerModule
	return r
}

// SetMaxSplitRate 设置最大分账比例
func (r *MerchIssueOpenRequest) SetMaxSplitRate(maxSplitRate string) *MerchIssueOpenRequest {
	r.MaxSplitRate = maxSplitRate
	return r
}

// SetSourceIDs 设置文件源ID列表
func (r *MerchIssueOpenRequest) SetSourceIDs(sourceIDs []string) *MerchIssueOpenRequest {
	r.SourceIDs = sourceIDs
	return r
}

// SetFeeRate 设置费率
func (r *MerchIssueOpenRequest) SetFeeRate(feeRate string) *MerchIssueOpenRequest {
	r.FeeRate = feeRate
	return r
}

// SetPbthf 设置平台补贴后费率
func (r *MerchIssueOpenRequest) SetPbthf(pbthf string) *MerchIssueOpenRequest {
	r.Pbthf = pbthf
	return r
}

// SetLowAmt 设置最低金额
func (r *MerchIssueOpenRequest) SetLowAmt(lowAmt string) *MerchIssueOpenRequest {
	r.LowAmt = lowAmt
	return r
}

// SetUpAmt 设置最高金额
func (r *MerchIssueOpenRequest) SetUpAmt(upAmt string) *MerchIssueOpenRequest {
	r.UpAmt = upAmt
	return r
}

// SetNotifyURL 设置通知URL
func (r *MerchIssueOpenRequest) SetNotifyURL(notifyURL string) *MerchIssueOpenRequest {
	r.NotifyURL = notifyURL
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchIssueOpenRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchIssueOpenRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchIssueOpenRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchIssueOpenRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}
	if r.LedgerModule != "" {
		baseMap["ledger_module"] = r.LedgerModule
	}
	if r.MaxSplitRate != "" {
		baseMap["max_split_rate"] = r.MaxSplitRate
	}
	if r.SourceIDs != nil && len(r.SourceIDs) > 0 {
		baseMap["source_ids"] = r.SourceIDs
	}
	if r.FeeRate != "" {
		baseMap["fee_rate"] = r.FeeRate
	}
	if r.Pbthf != "" {
		baseMap["pbthf"] = r.Pbthf
	}
	if r.LowAmt != "" {
		baseMap["low_amt"] = r.LowAmt
	}
	if r.UpAmt != "" {
		baseMap["up_amt"] = r.UpAmt
	}
	if r.NotifyURL != "" {
		baseMap["notify_url"] = r.NotifyURL
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchIssueOpenRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchIssueOpenResponse 商户分账开通响应
type MerchIssueOpenResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// ApplyStatus 申请状态
	ApplyStatus string `json:"apply_status,omitempty"`
}

// NewMerchIssueOpenResponse 创建商户分账开通响应
func NewMerchIssueOpenResponse() *MerchIssueOpenResponse {
	return &MerchIssueOpenResponse{}
}

// ==================== 商户分账查询 ====================

// MerchIssueQueryRequest 商户分账查询请求
type MerchIssueQueryRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchIssueQueryRequest 创建商户分账查询请求
func NewMerchIssueQueryRequest() *MerchIssueQueryRequest {
	req := &MerchIssueQueryRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchIssueQueryRequest) SetOrgCode(orgCode string) *MerchIssueQueryRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchIssueQueryRequest) SetMchID(mchID string) *MerchIssueQueryRequest {
	r.MchID = mchID
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchIssueQueryRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchIssueQueryRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchIssueQueryRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchIssueQueryRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchIssueQueryRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchIssueQueryResponse 商户分账查询响应
type MerchIssueQueryResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// LedgerModule 账本模块
	LedgerModule string `json:"ledger_module,omitempty"`
	// MaxSplitRate 最大分账比例
	MaxSplitRate interface{} `json:"max_split_rate,omitempty"`
	// FeeRate 费率
	FeeRate interface{} `json:"fee_rate,omitempty"`
	// Pbthf 平台补贴后费率
	Pbthf string `json:"pbthf,omitempty"`
	// LowAmt 最低金额
	LowAmt interface{} `json:"low_amt,omitempty"`
	// UpAmt 最高金额
	UpAmt interface{} `json:"up_amt,omitempty"`
	// NotifyURL 通知URL
	NotifyURL string `json:"notify_url,omitempty"`
	// ApplyStatus 申请状态
	ApplyStatus string `json:"apply_status,omitempty"`
	// Binds 绑定信息列表
	Binds []*Bind `json:"bind_list,omitempty"`
}

// NewMerchIssueQueryResponse 创建商户分账查询响应
func NewMerchIssueQueryResponse() *MerchIssueQueryResponse {
	return &MerchIssueQueryResponse{}
}

// Bind 绑定信息
type Bind struct {
	// RevMchID 接收方商户号
	RevMchID string `json:"rev_mch_id,omitempty"`
	// RevMchName 接收方商户名称
	RevMchName string `json:"rev_mch_name,omitempty"`
	// SourceIDs 文件源ID列表
	SourceIDs []string `json:"source_ids,omitempty"`
	// NotifyURL 通知URL
	NotifyURL string `json:"notify_url,omitempty"`
	// BindStatus 绑定状态
	BindStatus string `json:"bind_status,omitempty"`
}

// NewBind 创建绑定信息
func NewBind() *Bind {
	return &Bind{}
}

// SetRevMchID 设置接收方商户号
func (b *Bind) SetRevMchID(revMchID string) *Bind {
	b.RevMchID = revMchID
	return b
}

// SetRevMchName 设置接收方商户名称
func (b *Bind) SetRevMchName(revMchName string) *Bind {
	b.RevMchName = revMchName
	return b
}

// SetSourceIDs 设置文件源ID列表
func (b *Bind) SetSourceIDs(sourceIDs []string) *Bind {
	b.SourceIDs = sourceIDs
	return b
}

// SetNotifyURL 设置通知URL
func (b *Bind) SetNotifyURL(notifyURL string) *Bind {
	b.NotifyURL = notifyURL
	return b
}

// SetBindStatus 设置绑定状态
func (b *Bind) SetBindStatus(bindStatus string) *Bind {
	b.BindStatus = bindStatus
	return b
}

// ToMap 转换为map
func (b *Bind) ToMap() (map[string]interface{}, error) {
	result := make(map[string]interface{})

	if b.RevMchID != "" {
		result["rev_mch_id"] = b.RevMchID
	}
	if b.RevMchName != "" {
		result["rev_mch_name"] = b.RevMchName
	}
	if b.SourceIDs != nil && len(b.SourceIDs) > 0 {
		result["source_ids"] = b.SourceIDs
	}
	if b.NotifyURL != "" {
		result["notify_url"] = b.NotifyURL
	}
	if b.BindStatus != "" {
		result["bind_status"] = b.BindStatus
	}

	return result, nil
}

// ==================== 商户分账更新 ====================

// MerchIssueUpdateRequest 商户分账更新请求
type MerchIssueUpdateRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// LedgerModule 账本模块
	LedgerModule string `json:"ledger_module,omitempty"`
	// MaxSplitRate 最大分账比例
	MaxSplitRate string `json:"max_split_rate,omitempty"`
	// SourceIDs 文件源ID列表
	SourceIDs []string `json:"source_ids,omitempty"`
	// FeeRate 费率
	FeeRate string `json:"fee_rate,omitempty"`
	// Pbthf 平台补贴后费率
	Pbthf string `json:"pbthf,omitempty"`
	// LowAmt 最低金额
	LowAmt string `json:"low_amt,omitempty"`
	// UpAmt 最高金额
	UpAmt string `json:"up_amt,omitempty"`
	// NotifyURL 通知URL
	NotifyURL string `json:"notify_url,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchIssueUpdateRequest 创建商户分账更新请求
func NewMerchIssueUpdateRequest() *MerchIssueUpdateRequest {
	req := &MerchIssueUpdateRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchIssueUpdateRequest) SetOrgCode(orgCode string) *MerchIssueUpdateRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchIssueUpdateRequest) SetMchID(mchID string) *MerchIssueUpdateRequest {
	r.MchID = mchID
	return r
}

// SetLedgerModule 设置账本模块
func (r *MerchIssueUpdateRequest) SetLedgerModule(ledgerModule string) *MerchIssueUpdateRequest {
	r.LedgerModule = ledgerModule
	return r
}

// SetMaxSplitRate 设置最大分账比例
func (r *MerchIssueUpdateRequest) SetMaxSplitRate(maxSplitRate string) *MerchIssueUpdateRequest {
	r.MaxSplitRate = maxSplitRate
	return r
}

// SetSourceIDs 设置文件源ID列表
func (r *MerchIssueUpdateRequest) SetSourceIDs(sourceIDs []string) *MerchIssueUpdateRequest {
	r.SourceIDs = sourceIDs
	return r
}

// SetFeeRate 设置费率
func (r *MerchIssueUpdateRequest) SetFeeRate(feeRate string) *MerchIssueUpdateRequest {
	r.FeeRate = feeRate
	return r
}

// SetPbthf 设置平台补贴后费率
func (r *MerchIssueUpdateRequest) SetPbthf(pbthf string) *MerchIssueUpdateRequest {
	r.Pbthf = pbthf
	return r
}

// SetLowAmt 设置最低金额
func (r *MerchIssueUpdateRequest) SetLowAmt(lowAmt string) *MerchIssueUpdateRequest {
	r.LowAmt = lowAmt
	return r
}

// SetUpAmt 设置最高金额
func (r *MerchIssueUpdateRequest) SetUpAmt(upAmt string) *MerchIssueUpdateRequest {
	r.UpAmt = upAmt
	return r
}

// SetNotifyURL 设置通知URL
func (r *MerchIssueUpdateRequest) SetNotifyURL(notifyURL string) *MerchIssueUpdateRequest {
	r.NotifyURL = notifyURL
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchIssueUpdateRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchIssueUpdateRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchIssueUpdateRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchIssueUpdateRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}
	if r.LedgerModule != "" {
		baseMap["ledger_module"] = r.LedgerModule
	}
	if r.MaxSplitRate != "" {
		baseMap["max_split_rate"] = r.MaxSplitRate
	}
	if r.SourceIDs != nil && len(r.SourceIDs) > 0 {
		baseMap["source_ids"] = r.SourceIDs
	}
	if r.FeeRate != "" {
		baseMap["fee_rate"] = r.FeeRate
	}
	if r.Pbthf != "" {
		baseMap["pbthf"] = r.Pbthf
	}
	if r.LowAmt != "" {
		baseMap["low_amt"] = r.LowAmt
	}
	if r.UpAmt != "" {
		baseMap["up_amt"] = r.UpAmt
	}
	if r.NotifyURL != "" {
		baseMap["notify_url"] = r.NotifyURL
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchIssueUpdateRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchIssueUpdateResponse 商户分账更新响应
type MerchIssueUpdateResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// ApplyStatus 申请状态
	ApplyStatus string `json:"apply_status,omitempty"`
}

// NewMerchIssueUpdateResponse 创建商户分账更新响应
func NewMerchIssueUpdateResponse() *MerchIssueUpdateResponse {
	return &MerchIssueUpdateResponse{}
}

// ==================== 商户分账结算更新 ====================

// MerchRevSettleUpdateRequest 商户分账结算更新请求
type MerchRevSettleUpdateRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// BankCardNo 银行卡号
	BankCardNo string `json:"bank_card_no,omitempty"`
	// BankCardName 银行卡姓名
	BankCardName string `json:"bank_card_name,omitempty"`
	// BankCode 银行代码
	BankCode string `json:"bank_code,omitempty"`
	// BankName 银行名称
	BankName string `json:"bank_name,omitempty"`
	// BankBranchCode 银行支行代码
	BankBranchCode string `json:"bank_branch_code,omitempty"`
	// BankBranchName 银行支行名称
	BankBranchName string `json:"bank_branch_name,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchRevSettleUpdateRequest 创建商户分账结算更新请求
func NewMerchRevSettleUpdateRequest() *MerchRevSettleUpdateRequest {
	req := &MerchRevSettleUpdateRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchRevSettleUpdateRequest) SetOrgCode(orgCode string) *MerchRevSettleUpdateRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchRevSettleUpdateRequest) SetMchID(mchID string) *MerchRevSettleUpdateRequest {
	r.MchID = mchID
	return r
}

// SetBankCardNo 设置银行卡号
func (r *MerchRevSettleUpdateRequest) SetBankCardNo(bankCardNo string) *MerchRevSettleUpdateRequest {
	r.BankCardNo = bankCardNo
	return r
}

// SetBankCardName 设置银行卡姓名
func (r *MerchRevSettleUpdateRequest) SetBankCardName(bankCardName string) *MerchRevSettleUpdateRequest {
	r.BankCardName = bankCardName
	return r
}

// SetBankCode 设置银行代码
func (r *MerchRevSettleUpdateRequest) SetBankCode(bankCode string) *MerchRevSettleUpdateRequest {
	r.BankCode = bankCode
	return r
}

// SetBankName 设置银行名称
func (r *MerchRevSettleUpdateRequest) SetBankName(bankName string) *MerchRevSettleUpdateRequest {
	r.BankName = bankName
	return r
}

// SetBankBranchCode 设置银行支行代码
func (r *MerchRevSettleUpdateRequest) SetBankBranchCode(bankBranchCode string) *MerchRevSettleUpdateRequest {
	r.BankBranchCode = bankBranchCode
	return r
}

// SetBankBranchName 设置银行支行名称
func (r *MerchRevSettleUpdateRequest) SetBankBranchName(bankBranchName string) *MerchRevSettleUpdateRequest {
	r.BankBranchName = bankBranchName
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchRevSettleUpdateRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchRevSettleUpdateRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchRevSettleUpdateRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchRevSettleUpdateRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}
	if r.BankCardNo != "" {
		baseMap["bank_card_no"] = r.BankCardNo
	}
	if r.BankCardName != "" {
		baseMap["bank_card_name"] = r.BankCardName
	}
	if r.BankCode != "" {
		baseMap["bank_code"] = r.BankCode
	}
	if r.BankName != "" {
		baseMap["bank_name"] = r.BankName
	}
	if r.BankBranchCode != "" {
		baseMap["bank_branch_code"] = r.BankBranchCode
	}
	if r.BankBranchName != "" {
		baseMap["bank_branch_name"] = r.BankBranchName
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchRevSettleUpdateRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchRevSettleUpdateResponse 商户分账结算更新响应
type MerchRevSettleUpdateResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// ApplyStatus 申请状态
	ApplyStatus string `json:"apply_status,omitempty"`
}

// NewMerchRevSettleUpdateResponse 创建商户分账结算更新响应
func NewMerchRevSettleUpdateResponse() *MerchRevSettleUpdateResponse {
	return &MerchRevSettleUpdateResponse{}
}

// ==================== 商户分账绑定查询 ====================

// MerchRevBindQueryRequest 商户分账绑定查询请求
type MerchRevBindQueryRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// RevMchID 接收方商户号
	RevMchID string `json:"rev_mch_id,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchRevBindQueryRequest 创建商户分账绑定查询请求
func NewMerchRevBindQueryRequest() *MerchRevBindQueryRequest {
	req := &MerchRevBindQueryRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchRevBindQueryRequest) SetOrgCode(orgCode string) *MerchRevBindQueryRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchRevBindQueryRequest) SetMchID(mchID string) *MerchRevBindQueryRequest {
	r.MchID = mchID
	return r
}

// SetRevMchID 设置接收方商户号
func (r *MerchRevBindQueryRequest) SetRevMchID(revMchID string) *MerchRevBindQueryRequest {
	r.RevMchID = revMchID
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchRevBindQueryRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchRevBindQueryRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchRevBindQueryRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchRevBindQueryRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}
	if r.RevMchID != "" {
		baseMap["rev_mch_id"] = r.RevMchID
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchRevBindQueryRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchRevBindQueryResponse 商户分账绑定查询响应
type MerchRevBindQueryResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// RevMchID 接收方商户号
	RevMchID string `json:"rev_mch_id,omitempty"`
	// SourceIDs 文件源ID列表
	SourceIDs []string `json:"source_ids,omitempty"`
	// NotifyURL 通知URL
	NotifyURL string `json:"notify_url,omitempty"`
	// BindStatus 绑定状态
	BindStatus string `json:"bind_status,omitempty"`
}

// NewMerchRevBindQueryResponse 创建商户分账绑定查询响应
func NewMerchRevBindQueryResponse() *MerchRevBindQueryResponse {
	return &MerchRevBindQueryResponse{}
}

// ==================== 商户分账绑定 ====================

// MerchRevBindRequest 商户分账绑定请求
type MerchRevBindRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// RevMchID 接收方商户号
	RevMchID string `json:"rev_mch_id,omitempty"`
	// NotifyURL 通知URL
	NotifyURL string `json:"notify_url,omitempty"`
	// SourceIDs 文件源ID列表
	SourceIDs []string `json:"source_ids,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchRevBindRequest 创建商户分账绑定请求
func NewMerchRevBindRequest() *MerchRevBindRequest {
	req := &MerchRevBindRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchRevBindRequest) SetOrgCode(orgCode string) *MerchRevBindRequest {
	r.OrgCode = orgCode
	return r
}

// SetMchID 设置商户号
func (r *MerchRevBindRequest) SetMchID(mchID string) *MerchRevBindRequest {
	r.MchID = mchID
	return r
}

// SetRevMchID 设置接收方商户号
func (r *MerchRevBindRequest) SetRevMchID(revMchID string) *MerchRevBindRequest {
	r.RevMchID = revMchID
	return r
}

// SetNotifyURL 设置通知URL
func (r *MerchRevBindRequest) SetNotifyURL(notifyURL string) *MerchRevBindRequest {
	r.NotifyURL = notifyURL
	return r
}

// SetSourceIDs 设置文件源ID列表
func (r *MerchRevBindRequest) SetSourceIDs(sourceIDs []string) *MerchRevBindRequest {
	r.SourceIDs = sourceIDs
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchRevBindRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchRevBindRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchRevBindRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchRevBindRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}
	if r.RevMchID != "" {
		baseMap["rev_mch_id"] = r.RevMchID
	}
	if r.NotifyURL != "" {
		baseMap["notify_url"] = r.NotifyURL
	}
	if r.SourceIDs != nil && len(r.SourceIDs) > 0 {
		baseMap["source_ids"] = r.SourceIDs
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchRevBindRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchRevBindResponse 商户分账绑定响应
type MerchRevBindResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// RevMchID 接收方商户号
	RevMchID string `json:"rev_mch_id,omitempty"`
	// ApplyStatus 申请状态
	ApplyStatus string `json:"apply_status,omitempty"`
}

// NewMerchRevBindResponse 创建商户分账绑定响应
func NewMerchRevBindResponse() *MerchRevBindResponse {
	return &MerchRevBindResponse{}
}

// ==================== 商户分账开通 ====================

// MerchRevOpenRequest 商户分账开通请求
type MerchRevOpenRequest struct {
	models.OrgBaseRequest
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MerchType 商户类型
	MerchType string `json:"merch_type,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// LicenseNumber 营业执照号
	LicenseNumber string `json:"license_number,omitempty"`
	// LicenseName 营业执照名称
	LicenseName string `json:"license_name,omitempty"`
	// LicenseAddress 营业执照地址
	LicenseAddress string `json:"license_address,omitempty"`
	// LicenseBeginDate 营业执照开始日期
	LicenseBeginDate string `json:"license_begin_date,omitempty"`
	// LicenseEndDate 营业执照结束日期
	LicenseEndDate string `json:"license_end_date,omitempty"`
	// LicenseFrontSourceID 营业执照正面文件源ID
	LicenseFrontSourceID string `json:"license_front_source_id,omitempty"`
	// LegalName 法人姓名
	LegalName string `json:"legal_name,omitempty"`
	// LegalNumber 法人证件号
	LegalNumber string `json:"legal_number,omitempty"`
	// LegalBeginDate 法人证件开始日期
	LegalBeginDate string `json:"legal_begin_date,omitempty"`
	// LegalEndDate 法人证件结束日期
	LegalEndDate string `json:"legal_end_date,omitempty"`
	// LegalFrontSourceID 法人证件正面文件源ID
	LegalFrontSourceID string `json:"legal_front_source_id,omitempty"`
	// LegalBackSourceID 法人证件背面文件源ID
	LegalBackSourceID string `json:"legal_back_source_id,omitempty"`
	// Mobile 手机号
	Mobile string `json:"mobile,omitempty"`
	// BankCardNo 银行卡号
	BankCardNo string `json:"bank_card_no,omitempty"`
	// BankCardName 银行卡姓名
	BankCardName string `json:"bank_card_name,omitempty"`
	// BankCode 银行代码
	BankCode string `json:"bank_code,omitempty"`
	// BankName 银行名称
	BankName string `json:"bank_name,omitempty"`
	// BankBranchCode 银行支行代码
	BankBranchCode string `json:"bank_branch_code,omitempty"`
	// BankBranchName 银行支行名称
	BankBranchName string `json:"bank_branch_name,omitempty"`
	// BankFrontSourceID 银行卡正面照片的sourceId，开户类型为1、2时必传
	BankFrontSourceID string `json:"bank_front_source_id,omitempty"`
	// 原始请求映射数据
	rawRequestMap map[string]interface{} `json:"-"`
}

// NewMerchRevOpenRequest 创建商户分账开通请求
func NewMerchRevOpenRequest() *MerchRevOpenRequest {
	req := &MerchRevOpenRequest{}
	return req
}

// SetOrgCode 设置机构代码
func (r *MerchRevOpenRequest) SetOrgCode(orgCode string) *MerchRevOpenRequest {
	r.OrgCode = orgCode
	return r
}

// SetMerchType 设置商户类型
func (r *MerchRevOpenRequest) SetMerchType(merchType string) *MerchRevOpenRequest {
	r.MerchType = merchType
	return r
}

// SetMchID 设置商户号
func (r *MerchRevOpenRequest) SetMchID(mchID string) *MerchRevOpenRequest {
	r.MchID = mchID
	return r
}

// SetLicenseNumber 设置营业执照号
func (r *MerchRevOpenRequest) SetLicenseNumber(licenseNumber string) *MerchRevOpenRequest {
	r.LicenseNumber = licenseNumber
	return r
}

// SetLicenseName 设置营业执照名称
func (r *MerchRevOpenRequest) SetLicenseName(licenseName string) *MerchRevOpenRequest {
	r.LicenseName = licenseName
	return r
}

// SetLicenseAddress 设置营业执照地址
func (r *MerchRevOpenRequest) SetLicenseAddress(licenseAddress string) *MerchRevOpenRequest {
	r.LicenseAddress = licenseAddress
	return r
}

// SetLicenseBeginDate 设置营业执照开始日期
func (r *MerchRevOpenRequest) SetLicenseBeginDate(licenseBeginDate string) *MerchRevOpenRequest {
	r.LicenseBeginDate = licenseBeginDate
	return r
}

// SetLicenseEndDate 设置营业执照结束日期
func (r *MerchRevOpenRequest) SetLicenseEndDate(licenseEndDate string) *MerchRevOpenRequest {
	r.LicenseEndDate = licenseEndDate
	return r
}

// SetLicenseFrontSourceID 设置营业执照正面文件源ID
func (r *MerchRevOpenRequest) SetLicenseFrontSourceID(licenseFrontSourceID string) *MerchRevOpenRequest {
	r.LicenseFrontSourceID = licenseFrontSourceID
	return r
}

// SetLegalName 设置法人姓名
func (r *MerchRevOpenRequest) SetLegalName(legalName string) *MerchRevOpenRequest {
	r.LegalName = legalName
	return r
}

// SetLegalNumber 设置法人证件号
func (r *MerchRevOpenRequest) SetLegalNumber(legalNumber string) *MerchRevOpenRequest {
	r.LegalNumber = legalNumber
	return r
}

// SetLegalBeginDate 设置法人证件开始日期
func (r *MerchRevOpenRequest) SetLegalBeginDate(legalBeginDate string) *MerchRevOpenRequest {
	r.LegalBeginDate = legalBeginDate
	return r
}

// SetLegalEndDate 设置法人证件结束日期
func (r *MerchRevOpenRequest) SetLegalEndDate(legalEndDate string) *MerchRevOpenRequest {
	r.LegalEndDate = legalEndDate
	return r
}

// SetLegalFrontSourceID 设置法人证件正面文件源ID
func (r *MerchRevOpenRequest) SetLegalFrontSourceID(legalFrontSourceID string) *MerchRevOpenRequest {
	r.LegalFrontSourceID = legalFrontSourceID
	return r
}

// SetLegalBackSourceID 设置法人证件背面文件源ID
func (r *MerchRevOpenRequest) SetLegalBackSourceID(legalBackSourceID string) *MerchRevOpenRequest {
	r.LegalBackSourceID = legalBackSourceID
	return r
}

// SetMobile 设置手机号
func (r *MerchRevOpenRequest) SetMobile(mobile string) *MerchRevOpenRequest {
	r.Mobile = mobile
	return r
}

// SetBankCardNo 设置银行卡号
func (r *MerchRevOpenRequest) SetBankCardNo(bankCardNo string) *MerchRevOpenRequest {
	r.BankCardNo = bankCardNo
	return r
}

// SetBankCardName 设置银行卡姓名
func (r *MerchRevOpenRequest) SetBankCardName(bankCardName string) *MerchRevOpenRequest {
	r.BankCardName = bankCardName
	return r
}

// SetBankCode 设置银行代码
func (r *MerchRevOpenRequest) SetBankCode(bankCode string) *MerchRevOpenRequest {
	r.BankCode = bankCode
	return r
}

// SetBankName 设置银行名称
func (r *MerchRevOpenRequest) SetBankName(bankName string) *MerchRevOpenRequest {
	r.BankName = bankName
	return r
}

// SetBankBranchCode 设置银行支行代码
func (r *MerchRevOpenRequest) SetBankBranchCode(bankBranchCode string) *MerchRevOpenRequest {
	r.BankBranchCode = bankBranchCode
	return r
}

// SetBankBranchName 设置银行支行名称
func (r *MerchRevOpenRequest) SetBankBranchName(bankBranchName string) *MerchRevOpenRequest {
	r.BankBranchName = bankBranchName
	return r
}

// SetBankFrontSourceID 设置银行卡正面照片的sourceId
func (r *MerchRevOpenRequest) SetBankFrontSourceID(bankFrontSourceID string) *MerchRevOpenRequest {
	r.BankFrontSourceID = bankFrontSourceID
	return r
}

// SetRawRequestMap 设置原始请求映射数据
func (r *MerchRevOpenRequest) SetRawRequestMap(rawMap map[string]interface{}) *MerchRevOpenRequest {
	r.rawRequestMap = rawMap
	return r
}

// GetRawMap 获取原始请求映射数据
func (r *MerchRevOpenRequest) GetRawMap() (map[string]interface{}, bool) {
	return r.rawRequestMap, len(r.rawRequestMap) > 0
}

// ToMap 转换为map
func (r *MerchRevOpenRequest) ToMap() (map[string]interface{}, error) {
	// 如果有原始请求数据，优先使用
	if rawMap, hasRaw := r.GetRawMap(); hasRaw {
		return rawMap, nil
	}

	// 先获取基类的map
	baseMap, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加自己的字段
	if r.OrgCode != "" {
		baseMap["org_code"] = r.OrgCode
	}
	if r.MerchType != "" {
		baseMap["merch_type"] = r.MerchType
	}
	if r.MchID != "" {
		baseMap["mch_id"] = r.MchID
	}
	if r.LicenseNumber != "" {
		baseMap["license_number"] = r.LicenseNumber
	}
	if r.LicenseName != "" {
		baseMap["license_name"] = r.LicenseName
	}
	if r.LicenseAddress != "" {
		baseMap["license_address"] = r.LicenseAddress
	}
	if r.LicenseBeginDate != "" {
		baseMap["license_begin_date"] = r.LicenseBeginDate
	}
	if r.LicenseEndDate != "" {
		baseMap["license_end_date"] = r.LicenseEndDate
	}
	if r.LicenseFrontSourceID != "" {
		baseMap["license_front_source_id"] = r.LicenseFrontSourceID
	}
	if r.LegalName != "" {
		baseMap["legal_name"] = r.LegalName
	}
	if r.LegalNumber != "" {
		baseMap["legal_number"] = r.LegalNumber
	}
	if r.LegalBeginDate != "" {
		baseMap["legal_begin_date"] = r.LegalBeginDate
	}
	if r.LegalEndDate != "" {
		baseMap["legal_end_date"] = r.LegalEndDate
	}
	if r.LegalFrontSourceID != "" {
		baseMap["legal_front_source_id"] = r.LegalFrontSourceID
	}
	if r.LegalBackSourceID != "" {
		baseMap["legal_back_source_id"] = r.LegalBackSourceID
	}
	if r.Mobile != "" {
		baseMap["mobile"] = r.Mobile
	}
	if r.BankCardNo != "" {
		baseMap["bank_card_no"] = r.BankCardNo
	}
	if r.BankCardName != "" {
		baseMap["bank_card_name"] = r.BankCardName
	}
	if r.BankCode != "" {
		baseMap["bank_code"] = r.BankCode
	}
	if r.BankName != "" {
		baseMap["bank_name"] = r.BankName
	}
	if r.BankBranchCode != "" {
		baseMap["bank_branch_code"] = r.BankBranchCode
	}
	if r.BankBranchName != "" {
		baseMap["bank_branch_name"] = r.BankBranchName
	}
	if r.BankFrontSourceID != "" {
		baseMap["bank_front_source_id"] = r.BankFrontSourceID
	}

	return baseMap, nil
}

// CheckRequiredParams 检查必需参数
func (r *MerchRevOpenRequest) CheckRequiredParams(config *core.Config) error {
	// 与Python版本保持一致，不进行参数校验
	return nil
}

// MerchRevOpenResponse 商户分账开通响应
type MerchRevOpenResponse struct {
	models.StandardResponse
	// OrgCode 机构代码
	OrgCode string `json:"org_code,omitempty"`
	// MchID 商户号
	MchID string `json:"mch_id,omitempty"`
	// ApplyStatus 申请状态
	ApplyStatus string `json:"apply_status,omitempty"`
}

// NewMerchRevOpenResponse 创建商户分账开通响应
func NewMerchRevOpenResponse() *MerchRevOpenResponse {
	return &MerchRevOpenResponse{}
}
